import 'package:flutter/material.dart';
import 'package:get/get.dart';

class HomeController extends GetxController {
  // 应用信息
  final appTitle = 'XH弹幕组件演示'.obs;
  final appVersion = '1.0.0'.obs;

  // 菜单项
  final menuItems = <MenuItem>[
    MenuItem(
      title: '弹幕演示',
      subtitle: '体验高性能弹幕系统',
      icon: '🎬',
      route: '/danmu',
      color: const Color(0xFF4CAF50),
    ),
    MenuItem(
      title: '性能测试',
      subtitle: '测试大量弹幕性能',
      icon: '⚡',
      route: '/danmu?mode=performance',
      color: const Color(0xFF2196F3),
    ),
    MenuItem(
      title: '自定义样式',
      subtitle: '展示弹幕样式定制',
      icon: '🎨',
      route: '/danmu?mode=custom',
      color: const Color(0xFF9C27B0),
    ),
    MenuItem(
      title: '调试模式',
      subtitle: '可视化调试工具',
      icon: '🔧',
      route: '/danmu?mode=debug',
      color: const Color(0xFFFF9800),
    ),
  ].obs;

  @override
  void onInit() {
    super.onInit();
    _initializeApp();
  }

  void _initializeApp() {
    // 初始化应用相关设置
    // 初始化日志（仅调试模式）
    // print('XH弹幕演示应用初始化完成');
  }

  /// 导航到指定页面
  void navigateToPage(String route) {
    Get.toNamed(route);
  }

  /// 显示关于信息
  void showAbout() {
    Get.dialog(
      AlertDialog(
        title: const Text('关于应用'),
        content: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text('应用名称: ${appTitle.value}'),
            Text('版本: ${appVersion.value}'),
            const SizedBox(height: 16),
            const Text('XH弹幕组件特性:'),
            const Text('• 严格碰撞检测'),
            const Text('• 智能轨道分配'),
            const Text('• 完全离屏清理'),
            const Text('• 高性能动画'),
            const Text('• 丰富调试工具'),
          ],
        ),
        actions: [
          TextButton(
            onPressed: () => Get.back(),
            child: const Text('确定'),
          ),
        ],
      ),
    );
  }
}

class MenuItem {
  final String title;
  final String subtitle;
  final String icon;
  final String route;
  final Color color;

  MenuItem({
    required this.title,
    required this.subtitle,
    required this.icon,
    required this.route,
    required this.color,
  });
}
